package info.motteke.mixivoice4j.http.json.favorite.create;

import info.motteke.mixivoice4j.Entry;
import info.motteke.mixivoice4j.User;
import info.motteke.mixivoice4j.http.json.JsonRequestBuilder;

public class CreateFavoriteBuilder extends JsonRequestBuilder<CreateFavoriteRequest> {

    private Entry entry = null;

    private User user = null;

    protected CreateFavoriteBuilder() {

    }

    public CreateFavoriteBuilder entry(Entry entry) {
        this.entry = entry;
        return this;
    }

    public CreateFavoriteBuilder user(User user) {
        this.user = user;
        return this;
    }

    @Override
    public CreateFavoriteRequest build() {
        check(entry, "entry");
        check(user, "user");

        CreateFavoriteRequest req = new CreateFavoriteRequest();
        CreateFavoriteParam p = req.getParams();
        p.setOwnerId(entry.getUser().getId());
        p.setEntryId(entry.getId());
        p.setViewerId(user.getId());

        return req;
    }
}
